load("@semmle_code//:dist.bzl", "pack_zip")

py_binary(
    name = "make-zips-py",
    srcs = [
        "make_zips.py",
        "python_tracer.py",
        "unparse.py",
    ],
    data = [
        "LICENSE-PSF.md",
        "__main__.py",
        "imp.py",
    ] + glob([
        "blib2to3/**",
        "buildtools/**",
        "lark/**",
        "semmle/**",
    ]),
    # On @criemen's machine, without this, make-zips.py can't find its imports from
    # python_tracer. The problem didn't show for some reason on Windows CI machines, though.
    imports = ["."],
    main = "make_zips.py",
)

genrule(
    name = "python3src",
    outs = [
        "python3src.zip",
    ],
    cmd = "PYTHON_INSTALLER_OUTPUT=\"$(RULEDIR)\" $(location :make-zips-py)",
    tools = [":make-zips-py"],
)

pack_zip(
    name = "extractor",
    srcs = [
        "LICENSE-PSF.md",  # because we distribute imp.py
        "convert_setup.py",
        "get_venv_lib.py",
        "imp.py",
        "index.py",
        "python_tracer.py",
        "setup.py",
        ":python3src",
    ] + glob(["data/**"]),
    prefix = "tools",
    visibility = ["//visibility:public"],
)
